package com.feihao.zhou.demo03_ObjectStream;

import java.io.*;

public class ObjectStreamTest {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        Student student = new Student(13,"张三");

        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("student.txt"));

        //将对象写入内存文件中
        oos.writeObject(student);

        oos.close();


        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("student.txt"));

        Object o = ois.readObject();
        if (o instanceof Student){
            Student s = (Student) o;
            System.out.println(s);
        }

    }
}
